/*
 *  YATUN  - Yet another tunneling application
 *
 *  Michal Demin - 2007
 *
 *  Tunnel.h
 *
 */

#ifndef TUNNEL_H_
#define TUNNEL_H_


#include "Yatun.h"
#include "llist.h"
#include "SchedQueue.h"
#include "c_Plug_IO.h"

#define MAX(x,y) ((x)>(y)?(x):(y))

enum {DISCONNECTED, CONNECTED, WAITING }; 
enum {STOP, RUN, QUIT};

struct TunnelConf {
	int Reliable;
	struct timeval TunnelTimeout;
	LList *Chain;
	char *IfaceName;
	char *ScriptUP;
	char *ScriptDOWN;
//	c_Plug_IO *IOLocal;
//	c_Plug_IO *IORemote;

// scheduler 
	struct SchedQueueConf SchedConf;
};

class Tunnel {

	private:
	
		int Reliable;
		int Status;
		int State;
	
		struct timeval TunnelTimeout;
		
		LList *Chain;
		c_Plug_IO *IOLocal;
		c_Plug_IO *IORemote;
		SchedQueue* sQueue;
		Packet *Pack;
		
		char *IfaceName;
		char *ScriptUP;
		char *ScriptDOWN;

		void Init();
		
    public:
		Tunnel(c_Plug_IO *IOLocal, c_Plug_IO *IORemote);
		~Tunnel();
		
		int Run();
		void SetEventHandler(); // ? 
		void SetReliable(int);
		int GetStatus();
		void SetConf(struct TunnelConf &a);
};

#endif /*SCHEDQUEUE_H_*/
